package StringPractice;
import java.util.Scanner;

public class Password {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i = 0;
        for(i = 0;i < 3;i++) {
            System.out.print("请输入账号：");
            String name = sc.next();
            System.out.print("请输入密码：");
            String password = sc.next();
            boolean rs = CheckPassword(name, password);
            if (rs) {
                System.out.println("登录成功！");
                break;
            } else {
                int n = 2-i;
                System.out.println("登录失败，您还有" + n +"次机会");
            }
        }
    }

    public static boolean CheckPassword(String name,String password){
        String okName = "zhangsiyu";
        String okPassword = "zsy123456";
        return okName.equals(name) && okPassword.equals(password);
        }
    }
}
